package com.zwan.oam_rtc.utils.messages;

import com.zwan.oam_rtc.utils.wintcp.ByteTransfer;

import java.nio.ByteBuffer;

public class UserStatusUpdateMessage extends AbstractStruct {
    private byte[] messageBodyHeader = new byte[8];
    private byte[] tablename = new byte[50];
    private byte[] key = new byte[29];
    private byte[] registertime = new byte[20];

    private byte[] objectkey = new byte[500];

    private static int LENGTH = 8+599;

    /**
     * 返回消息写入buffer
     */
    @Override
    public void writeToBuffer(ByteBuffer bf) {
        bf.put(messageBodyHeader);
        bf.put(tablename);
        bf.put(key);
        bf.put(registertime);
        bf.put(objectkey);
    }

    /**
     * buffer读出返回消息
     */
    @Override
    public void readFromBuffer(ByteBuffer bf) {
        bf.get(messageBodyHeader);
        bf.get(tablename);
        bf.get(key);
        bf.get(registertime);
        bf.get(objectkey);
    }

    public String getTablename() {
        return ByteTransfer.getString(tablename);
    }

    public void setTablename(String tablename) {
        ByteTransfer.str2Byte(tablename, this.tablename);
    }

    public String getKey() {
        return ByteTransfer.getString(key);
    }

    public void setKey(String key) {
        ByteTransfer.str2Byte(key, this.key);
    }

    public String getRegistertime() {
        return ByteTransfer.getString(registertime);
    }

    public void setRegistertime(String registertime) {
        ByteTransfer.str2Byte(registertime, this.registertime);
    }

    public String getObjectkey() {
        return ByteTransfer.getString(objectkey);
    }
    public void setObjectkey(String objectkey) {
        ByteTransfer.str2Byte(objectkey, this.objectkey);
    }

    @Override
    public int getLength() {
        return LENGTH;
    }


}

